#include "../include/login.h"
#include "../include/password.h"

//账户系统:进入账户修改系统,可以进行对账号的增删改查
//参数:链表头节点和登录权限
//返回值:0
char dev_buff[1024]={0};
int device_system(int client_socket){
	int ch = 0;
	TRAN node;
	while(ch!=-1){
		bzero(&node,sizeof(node));
		//选择菜单
		printf("请选择设备操作:\n1:数据监测\n2设备管理:\n3:退出");
		scanf("%d",&ch);
		if(ch!=1 && ch!=2){//退出
			break;
		}
	return 0;	
}

void pas_packJson(void)
{
	
}

void _packJson(TRAN *node,int sel)
{
	if(sel == 1){//注销
		strcpy(node->order,"delete");
	}else if(sel == 2){//修改
		strcpy(node->order,"modify");
	}
	strcpy(node->name,m_node.name);
	
	cJSON* root = cJSON_CreateObject();
	cJSON* order = cJSON_CreateString(node->order);
	cJSON* name = cJSON_CreateString(node->name);
	cJSON* pas = cJSON_CreateString(node->pas);;
	cJSON* newpas = cJSON_CreateString("");

	cJSON_AddItemToObject(root,"order",order);
	cJSON_AddItemToObject(root,"name",name);
	if(sel==1){//注销
		cJSON_AddItemToObject(root,"pwd",pas);
		cJSON_AddItemToObject(root,"new_pwd",newpas);
	}else if(sel==2){//修改
		cJSON_AddItemToObject(root,"pwd",newpas);
		cJSON_AddItemToObject(root,"new_pwd",pas);
	}
	char *p=pas_buff;
	p=cJSON_Print(root);
	strcpy(pas_buff,p);
	cJSON_Delete(root);
}